//#define __DEBUG__
#define THIS_FILE "fn_checkoriginalside.sqf"
#include "x_setup.sqf"

private ["_s", "_r", "_rd"];
_s = _this getVariable "KEGs_oside";
if (isNil "_s") then {
	if (alive _this && {!captive _this}) then {
		_r = rating _this;
		if (_r < 0) then {
			_rd = abs _r;
			_this addRating _rd;
			_s = side (group _this);
			_this addRating -_rd;
		} else {
			_s = side (group _this);
		};
		_this setVariable ["KEGs_oside", _s];
	} else {
		_s = switch (getNumber(configFile/"CfgVehicles"/typeOf _this/"side")) do {
			case 0: {opfor};
			case 1: {blufor};
			case 2: {independent};
			default {civilian};
		};
		_this setVariable ["KEGs_oside", _s];
	}
};
_s